<template>
	<view class="main">
		<view class="conttitle" style="cursor: pointer;">
			<view style="height: 100%;">
				<view style="margin-top: 10px;" class="name"><span>剑魂</span><span>本人</span></view>
				<view style="margin-top: 20px;" class="phone">622*********0909</view>
			</view>
			<view style="margin-top: 20px;" class="mor">
				默认就诊人
			</view>
		</view>
		<view class="name">
			科室-保健科
		</view>
		<view class="sthtitle">
			选择预约时间
		</view>
		<view class="timeselect">
			<view class="week ali">
				<view class="flex1 weeklist" v-for="(item,index) in week">
					{{index==0?'今日':week[index]}}
				</view>
			</view>
			<view class="datelist ali">
				<view class="flex1 date" :class=" chooseindex==index?'choosed ':''" @click="chooseindex=index"
					v-for="(item,index) in dates" :key="index">
					{{item}}
				</view>
			</view>
		</view>
		<view class="sourcetitle">
			上午号源
		</view>
		<view class="morning">
			<view class="sourcelist" v-for="(item,index) in list[chooseindex].am" :key="index"
				:class="index%3==1 ?'sourcelistmargin '+(item>0?'less':''):(item>0?'less':'')"
				@click="item>0?tosth():'' ">
				{{time[index]}} 剩余
				{{item}}
			</view>

			<view class="clear">

			</view>
		</view>
		<view class="clear">

		</view>
		<view class="sourcetitle ">
			下午号源
		</view>


		<view class="afternoon">
			<view class="sourcelist" v-for="(item,index) in list[chooseindex].pm" :key="index"
				:class="index%3==1 ?'sourcelistmargin'+' '+(item>0?'less':''):(item>0?'less':'')"
				@click="item>0?tosth():'' ">
				{{time[index]}} 剩余
				{{item}}
			</view>

			<view class="clear">

			</view>
		</view>

	</view>
</template>
<script>
	import {
		request
	} from '@/util/do.js'
	export default {
		data() {
			return {
				chooseindex: 0,
				dates: [],
				week: [],
				list: [],
				time: [
					"9:00",
					"9:30",
					"10:00",
					"10:30",
					"11:00",
					"11:30"
				]
			}
		},
		methods: {
			tosth() {
				uni.navigateTo({
					url: '/query/page/confirmappoinmentmessage/confirmappoinmentmessage'
				})
			},
			sourcelist() {
				let _self = this
				request(
					'/sourcelist', {},
					"GET",
					function(res) {
						_self.list = res.data.data.list
					}
				)
			}
		},
		mounted() {
			this.sourcelist()
			var weeks = new Array("周日", "周一", "周二", "周三", "周四", "周五", "周六");
			const today = new Date().toISOString().slice(0, 10);
			const dates = [];
			for (let i = 0; i < 7; i++) {
				const date = new Date(Date.parse(today) + i * 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
				dates.push(date);
				this.dates.push(new Date(date).getDate())
				this.week.push(weeks[new Date(date).getDay()])
			}
		}
	}
</script>
<style>
	.name {
		font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
		font-weight: 400;
		font-style: normal;
		color: #AAAAAA;
		font-size: 28rpx;
		margin: 20rpx 0;
	}

	.sourcetitle {
		font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
		font-weight: 400;
		font-style: normal;
		color: #AAAAAA;
		margin: 8rpx 0;
		font-size: 28rpx;
	}

	.sthtitle {
		font-family: 'PingFangSC-Medium', 'PingFang SC Medium', 'PingFang SC', sans-serif;
		font-weight: 500;
		font-style: normal;
		font-size: 30rpx;
		margin: 20rpx 0;
	}

	.main {
		width: 92%;
		margin: 0 auto;
	}

	.timeselect {
		background-color: #fff;
		height: 200rpx;
		border: 1rpx solid #f2f2f2;
	}

	.ali {
		display: flex;
		align-items: center;
	}

	.flex {
		display: flex;
	}

	.flex1 {
		flex: 1;
		/* border: 1px solid red */
	}

	.izpimg img {
		width: 10px;
		height: 10px;
		margin-right: 30px;
	}

	.server1 {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		color: #757575;
		height: 56px;
		line-height: 56px;
		border-bottom: 1px solid rgba(242, 242, 242, 1);
		font-size: 15px;
	}

	.conttitle {
		background-color: #f5f9ff;
		height: 180rpx;
		display: flex;
		font-weight: 200;
		border: 1px solid #f2f2f2;
		padding: 20px 10px;
		justify-content: space-between;
		margin-top: 15px;
		box-sizing: border-box;
	}

	.mor {
		font-family: 'PingFangSC-Light', 'PingFang SC Light', 'PingFang SC', sans-serif;
		font-weight: 200;
		font-style: normal;
		font-size: 12px;
	}

	.phone {
		font-weight: 200;
		font-style: normal;
		font-size: 12px;
		color: #AAAAAA;
	}

	.name span:nth-child(1) {
		font-family: 'PingFangSC-Regular', 'PingFang SC', sans-serif;
		font-weight: 400;
		font-style: normal;
		font-size: 15px;
		color: #555555;
	}

	.name span:nth-child(2) {
		margin-left: 5px;
		font-size: 12px;
		display: inline-block;
		width: 44px;
		height: 18px;
		padding: 2px;
		background-color: #e2edfe;
		text-align: center;
		line-height: 18px;
		border-radius: 10px;
		letter-spacing: 1px;
		color: #006EFF;
	}

	.weeklist {
		font-weight: 200;
		margin-top: 20rpx;
		font-size: 24rpx;
		color: rgb(170, 170, 170);
		text-align: center;
	}

	.date {
		text-align: center;
		background-color: rgba(0, 110, 255, 0.098);
		border-radius: 40px;
		width: 20rpx;
		height: 32px;
		margin: 20rpx 10rpx 40rpx 10rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.choosed {
		background-color: rgb(0, 110, 255);
		color: #fff;
	}

	.sourcelist {
		float: left;
		width: calc(33% - 10rpx);
		text-align: center;
		color: rgb(170, 170, 170);
		background-color: rgba(0, 110, 255, 0.055);
		border-radius: 8rpx;
		box-shadow: none;
		height: 64rpx;
		font-weight: 400;
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 15rpx 0;
	}

	.sourcelistmargin {
		margin: 15rpx;
	}

	.less {
		color: #006EFF;
		background-color: #eff6ff;
	}
</style>